package com.design_mode;

/**
 * Created by dustaple on 8/4/14.
 */
public class ProxyPattern {
    public static void main(String[] args) {
        IPlayer player = new PlayerOne();
        IPlayer proxy = new PlayerProxy(player);
        proxy.killing();
        proxy.upgrade();
        proxy.buyTools();
    }
}

interface IPlayer {
    void killing();

    void upgrade();

    void buyTools();
}

class PlayerOne implements IPlayer {
    @Override
    public void killing() {
        System.out.println("杀怪！！！");
    }

    @Override
    public void upgrade() {
        System.out.println("升级！！！");
    }

    @Override
    public void buyTools() {
        System.out.println("购买道具");
    }
}

class PlayerProxy implements IPlayer {
    IPlayer subject;

    public PlayerProxy() {
        subject = new PlayerProxy();
    }

    public PlayerProxy(IPlayer player) {
        subject = player;
    }

    @Override
    public void killing() {
        subject.killing();
    }

    @Override
    public void upgrade() {
        subject.upgrade();
    }

    @Override
    public void buyTools() {
        System.out.println("没有权限购买道具。");
    }
}

